package com.zy.sorttedset;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/6 16:14
 **/
public class Per{
    private String name;
    private int age;

    public Per(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Per{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Per){
            Per p = (Per)obj;
            return this.getName().hashCode() + this.getAge()  == p.getName().hashCode() + p.getAge();
        }
        return false;
    }
//
//    @Override
//    public int compareTo(Object o) {
//        if(o instanceof Per){
//            Per p = (Per)o;
//            return this.getAge() - p.getAge();
//        }
//        return -1;
//    }
}
